<html>
<head>
    <meta content="text/html; charset=utf-8" http-equiv="content-type">
    <title>
        js调用java
    </title>
</head>

<body>
分享页面

<input type="button" value="上传图片" onclick="uploadAppPhoto(1)">
</body>
<script type="text/javascript">

function connectWebViewJavascriptBridge(callback) {
            if (window.WebViewJavascriptBridge) {
                callback(WebViewJavascriptBridge)
            } else {
                document.addEventListener(
                    'WebViewJavascriptBridgeReady'
                    , function() {
                        callback(WebViewJavascriptBridge)
                    },
                    false
                );
            }
        }

 connectWebViewJavascriptBridge(function(bridge) {

            bridge.registerHandler("getShareContent", function(data, responseCallback) {

                var responseData = {
                                        "url": "http://www.mljr.com",
                                        "title": "金融服务帮助年轻人实现美好生活",
                                        "content": "美利金融-以金融服务帮助年轻人创造美好生活，为投资理财人群提供高收益、低风险的互联网理财产品，为借款人群提供小额、短期的个人消费贷款。",
                                        "img": "https://www.mljr.com/favicon.ico"
                                    };
                responseCallback(responseData);
            });



        });





function appShare() {
              //call native method
            window.WebViewJavascriptBridge.callHandler(
                'appShare'
                , ''
                , function(responseData) {

                }
            );
        }




connectWebViewJavascriptBridge(function(bridge) {

 bridge.registerHandler("setPhotoBase64", function(data, responseCallback) {
                var photo = JSON.parse(data) ;

               setBase64Code(photo.base64Code,photo.position);
            });
});


function uploadAppPhoto(postion) {
              //call native method
            window.WebViewJavascriptBridge.callHandler(
                'uploadAppPhoto'
                , postion
                , function(responseData) {

                }
            );
        }




function cleanCache() {
              //call native method
            window.WebViewJavascriptBridge.callHandler(
                'cleanCache'
                , ''
                , function(responseData) {

                }
            );
        }

function getPayDeviceInfo() {
              //call native method
            window.WebViewJavascriptBridge.callHandler(
                'getPayDeviceInfo'
                , ''
                , function(responseData) {
                var deviceInfo = responseData.split(',')
                getAndroidNum(deviceInfo[0],deviceInfo[1]);
                }
            );
        }
function getMapLocation() {
              //call native method
            window.WebViewJavascriptBridge.callHandler(
                'getMapLocation'
                , ''
                , function(responseData) {
                 alert(responseData);
                }
            );
        }



function setBase64Code(base64, position){

        document.getElementById("photo1").src=base64;

    }





</script>

<img   id="photo1" />

<a href="mljr://api.mljr.com/openApp?action=1" >打开美利金融</a>
<a href="javascript:getMapLocation();" >定位</a>

</html>